<!doctype html>
{% extends "base.html" %}
{% block title %}应用部署{% endblock title %}

{% block page1_show %}show{% endblock page1_show %}
{% block page1.2_active %}active{% endblock page1.2_active %}

{% block main_content %}
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title">应用列表</h5>
                <h6 class="card-subtitle text-muted">
                <a style="margin-right: 10px;">获取每一台主机当前已部署的应用</a>
                <a href="/getInstalled" class="btn btn-primary">立即更新</a>
                </h6>
            </div>
            <table class="table table-striped table-hover table-bordered">
                <thead>
                    <tr>
                        <th>主机</th>
                        {% for app in AppList %}
                        <th>{{app}}</th>
                        {% endfor %}
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for host,install in Installed.items %}
                    <tr>
                        <td>{{ host }}</td>
                        {% for key,item in install.items %}
                            <td>{{ item }}</td>
                        {% endfor %}
                        <td class="table-action" style="width: 10%;">
                            <a href="" style="margin-right: 10px;"  data-toggle="modal" data-target="#set{{ host }}"><i class="fe fe-edit-2"></i></a>
                            <div class="modal fade" id="set{{ host }}" tabindex="-1" role="dialog" aria-hidden="true">
                                <div class="modal-dialog modal-dialog-centered" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h1 class="modal-title">为{{ host }}部署应用</h1>
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        </div>
                                        <div class="modal-body m-3">
                                            <form method="post" action="/addapp">
                                                <input type="hidden" readonly="readonly" name="host" value="{{ host }}">
                                                {% for key,item in install.items %}
                                                <div class="form-group row">
                                                    <label class="col-form-label col-sm-4 text-sm-right">{{ key }}</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" class="form-control" readonly="readonly" value="{{ item }}">
                                                    </div>
                                                    <div class="col-sm-3">
                                                        <label class="custom-control custom-checkbox">
                                                            <input type="checkbox" class="custom-control-input" name="{{ key }}">
                                                            <span class="custom-control-label">安装</span>
                                                        </label>
                                                    </div>
                                                </div>
                                                {% endfor %}
                                                <div class="modal-footer">
                                                    <div class="col-sm-5">
                                                        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                                                    </div>
                                                    <div class="col-sm-5">
                                                        <button type="submit" class="btn btn-primary">提 交</button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock main_content %}

{% block script %}
button.onclick = function () {
    window.location.href='index.jsp';
}
{% endblock script %}